class TrafficStats {
  final DateTime timestamp;
  final int uploadSpeed;
  final int downloadSpeed;
  final int totalUpload;
  final int totalDownload;

  TrafficStats({
    required this.timestamp,
    required this.uploadSpeed,
    required this.downloadSpeed,
    required this.totalUpload,
    required this.totalDownload,
  });

  Map<String, dynamic> toJson() {
    return {
      'timestamp': timestamp.toIso8601String(),
      'uploadSpeed': uploadSpeed,
      'downloadSpeed': downloadSpeed,
      'totalUpload': totalUpload,
      'totalDownload': totalDownload,
    };
  }

  factory TrafficStats.fromJson(Map<String, dynamic> json) {
    return TrafficStats(
      timestamp: DateTime.parse(json['timestamp']),
      uploadSpeed: json['uploadSpeed'],
      downloadSpeed: json['downloadSpeed'],
      totalUpload: json['totalUpload'],
      totalDownload: json['totalDownload'],
    );
  }
}
